<template>
  <div class="page">
    <div class="main">
      <div class="top">
        <h1>
          <p>{{ form.notName }}</p>
          <p>关于{{ form.effectRange }}({{ form.eventName }}){{ form.responseLvName }}应急响应命令</p>
          <p>〔{{ new Date().getFullYear() }}〕第<span class="num">
              {{ num }} </span>号
          </p>
        </h1>
      </div>
      <div class="content">
        <img src="../../../../assets/img/seal.png" alt="" srcset="" class="seal">
        <el-descriptions :column="2"
          :labelStyle="{ width: '110px', 'min-width': '110px', display: 'flex', justifyContent: 'flex-end' }">
          <el-descriptions-item label="签发人">{{ form.approvalUser }}</el-descriptions-item>
          <el-descriptions-item label="时间">{{ form.createTime }}</el-descriptions-item>
          <el-descriptions-item label="主送单位" span="2">{{ form.mainUnitName }}</el-descriptions-item>
          <el-descriptions-item label="响应部门" span="2">{{ form.responseDeptName }}</el-descriptions-item>
          <el-descriptions-item label="事件类别">{{ form.eventName }}</el-descriptions-item>
          <el-descriptions-item label="响应级别">{{ form.responseLvName }}</el-descriptions-item>
          <el-descriptions-item label="影响范围">{{ form.effectRange }}</el-descriptions-item>
          <el-descriptions-item label="影响时间">{{ form.effectTime }}</el-descriptions-item>
          <el-descriptions-item label="信息来源" span="2">{{ form.infoSourceName }}</el-descriptions-item>
          <el-descriptions-item label="事件概要" span="2">{{ form.incidentOutline }}</el-descriptions-item>
          <el-descriptions-item label="有关措施要求" span="2">
            <el-table :data="tableData" border style="width: 100%">
              <el-table-column type="index" label="序号" width="90" align="center">
              </el-table-column>
              <el-table-column prop="measureRequire" label="有关措施要求" align="center">
                <template slot-scope="scope">
                  <div style="text-align: left;">{{ scope.row.measureRequire }}</div>
                </template>
              </el-table-column>
              <el-table-column prop="unitDeptName" label="部门/单位" align="center" width="247">
              </el-table-column>
            </el-table>
          </el-descriptions-item>
          <el-descriptions-item label="联系人" span="2">
            <div>
              <p v-for="(item, i) in form.linkman_list" :key="i" style="padding-bottom: 3px;">
                {{ item }}{{ i == form.linkman_list.length - 1 ? "" : "；" }}
              </p>
            </div>
          </el-descriptions-item>
          <el-descriptions-item label="抄报">{{ form.outTheNewspaper }}</el-descriptions-item>
          <el-descriptions-item label="抄送">{{ form.sendDuplicate }}</el-descriptions-item>
        </el-descriptions>
      </div>
    </div>
  </div>
</template>

<script>
import {
  getinfo
} from "@/api/EmergencyDisposal/xymld";
export default {
  name: "EmergencyResponsepreview",
  components: {},
  props: {
    previewVisible: {
      type: Boolean,
      default: false
    },
    id: {
      type: [String, Number],
      default: function () {
        return "";
      }
    }
  },
  data() {
    return {
      tableData: [],
      form: {},
      num: ""
    };
  },
  watch: {
    previewVisible: {
      handler(val) {
        if (val) {
          this.getinfo();
        }
      },
      deep: true,
      immediate: true
    }
  },
  // computed: {
  //   num() {
  //     return this.form.number < 10 ? `0${this.form.number}` : this.form.number;
  //   }
  // },
  methods: {
    async getinfo() {
      const res = await getinfo({ id: this.id });
      this.form = res;
      const textNum = res.responseName.split("第");
      this.num = textNum[1].split("号")[0];
      this.form.linkman_list = res.linkman ? res.linkman.split(",") : [];
      this.form.mainUnitName = this.form.mainUnitName.replace(/[,，]/g, "、");
      this.form.responseDeptName = this.form.responseDeptName.replace(/[,，]/g, "、");
      this.tableData = res.emergencyMeasureListVos;
    }
  }
};
</script>

<style scoped lang="less">
:deep(.el-descriptions) {
  font-size: 16px;
}

:deep(.el-descriptions :not(.is-bordered) .el-descriptions-item__cell) {
  padding-bottom: 20px;
}

:deep(.el-descriptions-item__label:not(.is-bordered-label)) {
  margin-right: 20px;
}

:deep(.el-table thead) {
  color: #606266;
}

:deep(.el-table th.el-table__cell) {
  padding-top: 5px;
  padding-bottom: 5px;
}

.num {
  display: inline-block;
  padding: 2px 6px;
  font-size: 22px;
  // border: 1px solid #333;
  vertical-align: middle;
  margin: 0 10px;
}

.top {
  text-align: center;
  // width: 50%;
  // margin-left: 22%;
  margin-bottom: 30px;
}

.title {
  border-bottom: 1px solid #ccc;
  padding-bottom: 8px;
}

.card {
  margin-bottom: 20px;

  p {
    font-size: 16px;
    margin-top: 12px;
  }
}

.content {
  position: relative;
  // padding-top: 50px;
  padding: 50px 40px 20px 40px;
  box-sizing: border-box;

  .seal {
    position: absolute;
    top: 0;
    left: 240px;
    width: 150px;
    height: 150px;
  }
}
</style>
